<template>
  <Dialog width="800px" :footer="false" title="文本⽣成状态" v-model="dialogVisible">
    <el-table v-loading="isLoading" :data="dataList">
      <el-table-column label="声纹" align="center" prop="audioToneName" />
      <el-table-column label="生成状态" align="center" prop="statusText" />
      <el-table-column label="⽣成时间（以最后⼀次为准）" align="center" prop="createTimeText" />
    </el-table>
  </Dialog>
</template>

<script setup>
import { AudioTextApi } from '@/api/lm/audiotext';
import dayjs from "dayjs";
const dialogVisible = ref(false);
const dataList = ref([]);
const isLoading = ref(false);

const open = (id)=> {
  dialogVisible.value = true;
  dataList.value = [];
  isLoading.value = true;
  AudioTextApi.getRoleTextAudioRecord({
    pageNo: 0,
    pageSize: 100,
    audioTextId: id,
  }).then(e=> {
    dataList.value = e.list.map(item=> {
      item.createTimeText = dayjs(item.createTime).format('YYYY-MM-DD HH:mm:ss');
      switch(+item.status) {
        case 0:
          item.statusText = "待生成音频"
          break;
        case 1:
          item.statusText = "已完成"
          break;
        default:
          item.statusText = "准备中"
      }

      return item;
    });
  }).finally(e=> {
    isLoading.value = false;
  });
}

defineExpose({
  open
})
</script>
